#include"ThreadPool2.h"
#include<functional>
#include<memory>
using std::unique_ptr;
using std::function;
using std::bind;

class MyTask
{
public:
    void process()
    {
        ::srand(::clock());
        int number = ::rand()%100;
        cout << ">>MyTask process number = " << number << endl;
    }
};

void test0(){
    ThreadPool pool(3,10);
    unique_ptr<MyTask> my1(new MyTask());
    pool.start();
    int cnt = 20;
    while(cnt--){
        cout<<"cnt = "<<cnt<<endl;
        pool.addTask(bind(&MyTask::process,my1.get()));
    }
    
    pool.stop();
}

int main(void){
    
    test0();
    return 0;
}